package com.ruoyi.web.controller.tool;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.json.JSONObject;
import com.ruoyi.common.utils.http.RestTemplateUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/toolset/surface")
public class ToolsetController {

    private String prefix = "tool/surface";

    @GetMapping()
    public String build()
    {
        return prefix + "/surface";
    }

    @GetMapping("/map/maptx")
    public String map() {
        return prefix + "/map/maptx";
    }

    /**
     * 根据地名搜索
     */
    @GetMapping("/map/maptx/adress")
    @ResponseBody
    public AjaxResult userModel(HttpServletRequest request)
    {
        String keyword = request.getParameter("keyword");
        AjaxResult ajax = new AjaxResult();
        ajax.put("code", 200);
        ResponseEntity<JSONObject> jsonObjectResponseEntity = RestTemplateUtils.get("https://apis.map.qq.com/ws/place/v1/suggestion/?region=武汉&key=3SHBZ-SCS6D-PYT4Y-PK36K-OC6E7-64FTO&keyword="+keyword, JSONObject.class);
        ajax.put("value", jsonObjectResponseEntity);
        return ajax;
    }






}
